" cogl_color_out.rgb *= brightness; \n";
#define MIN_DOWNSCALE_SIZE 256.f
-#define MAX_SIGMA 6.f
+#define MAX_RADIUS 12.f
typedef enum
{
ShellBlurMode mode;
float downscale_factor;
float brightness;
- int sigma;
+ int radius;
};
G_DEFINE_TYPE (ShellBlurEffect, shell_blur_effect, CLUTTER_TYPE_EFFECT)
enum {
PROP_0,
- PROP_SIGMA,
+ PROP_RADIUS,
PROP_BRIGHTNESS,
PROP_MODE,
N_PROPS
static float
calculate_downscale_factor (float width,
float height,
- float sigma)
+ float radius)
{
float downscale_factor = 1.0;
float scaled_width = width;
float scaled_height = height;
- float scaled_sigma = sigma;
+ float scaled_radius = radius;
/* This is the algorithm used by Firefox; keep downscaling until either the
* blur radius is lower than the threshold, or the downscaled texture is too
* small.
*/
- while (scaled_sigma > MAX_SIGMA &&
+ while (scaled_radius > MAX_RADIUS &&
scaled_width > MIN_DOWNSCALE_SIZE &&
scaled_height > MIN_DOWNSCALE_SIZE)
{
scaled_width = width / downscale_factor;
scaled_height = height / downscale_factor;
- scaled_sigma = sigma / downscale_factor;
+ scaled_radius = radius / downscale_factor;
}
return downscale_factor;
blur_node = clutter_blur_node_new (self->tex_width / self->downscale_factor,
self->tex_height / self->downscale_factor,
- self->sigma / self->downscale_factor);
+ self->radius / self->downscale_factor);
clutter_paint_node_set_static_name (blur_node, "ShellBlurEffect (blur)");
clutter_paint_node_add_child (brightness_node, blur_node);
clutter_paint_node_add_rectangle (blur_node,
clutter_actor_box_get_size (source_actor_box, &width, &height);
- downscale_factor = calculate_downscale_factor (width, height, self->sigma);
+ downscale_factor = calculate_downscale_factor (width, height, self->radius);
updated = update_actor_fbo (self, width, height, downscale_factor) &&
update_brightness_fbo (self, width, height, downscale_factor);
g_assert (self->actor != NULL);
- if (self->sigma > 0)
+ if (self->radius > 0)
{
g_autoptr (ClutterPaintNode) blur_node = NULL;
switch (prop_id)
{
- case PROP_SIGMA:
- g_value_set_int (value, self->sigma);
+ case PROP_RADIUS:
+ g_value_set_int (value, self->radius);
break;
case PROP_BRIGHTNESS:
switch (prop_id)
{
- case PROP_SIGMA:
- shell_blur_effect_set_sigma (self, g_value_get_int (value));
+ case PROP_RADIUS:
+ shell_blur_effect_set_radius (self, g_value_get_int (value));
break;
case PROP_BRIGHTNESS:
effect_class->paint_node = shell_blur_effect_paint_node;
- properties[PROP_SIGMA] =
- g_param_spec_int ("sigma",
- "Sigma",
- "Sigma",
+ properties[PROP_RADIUS] =
+ g_param_spec_int ("radius",
+ "Radius",
+ "Radius in pixels",
0, G_MAXINT, 0,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
shell_blur_effect_init (ShellBlurEffect *self)
{
self->mode = SHELL_BLUR_MODE_ACTOR;
- self->sigma = 0;
+ self->radius = 0;
self->brightness = 1.f;
self->actor_fb.pipeline = create_base_pipeline ();
}
int
-shell_blur_effect_get_sigma (ShellBlurEffect *self)
+shell_blur_effect_get_radius (ShellBlurEffect *self)
{
g_return_val_if_fail (SHELL_IS_BLUR_EFFECT (self), -1);
- return self->sigma;
+ return self->radius;
}
void
-shell_blur_effect_set_sigma (ShellBlurEffect *self,
- int sigma)
+shell_blur_effect_set_radius (ShellBlurEffect *self,
+ int radius)
{
g_return_if_fail (SHELL_IS_BLUR_EFFECT (self));
- if (self->sigma == sigma)
+ if (self->radius == radius)
return;
- self->sigma = sigma;
+ self->radius = radius;
self->cache_flags &= ~BLUR_APPLIED;
if (self->actor)
clutter_effect_queue_repaint (CLUTTER_EFFECT (self));
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SIGMA]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_RADIUS]);
}
float
CoglPipeline *pipeline;
CoglTexture *texture;
float sampling_radius;
- float sigma;
+ float radius;
int src_height, dst_height;
int src_width, dst_width;
CoglPipeline *texture_pipeline;
g_return_val_if_fail (shadow_spec != NULL, NULL);
g_return_val_if_fail (src_texture != NULL, NULL);
- sampling_radius = resource_scale * shadow_spec->blur;
- sigma = sampling_radius / 2.f;
- sampling_radius = ceilf (sampling_radius);
+ radius = resource_scale * shadow_spec->blur;
+ sampling_radius = ceilf (radius);
src_width = cogl_texture_get_width (src_texture);
src_height = cogl_texture_get_height (src_texture);
cogl_framebuffer_orthographic (fb, 0, 0, dst_width, dst_height, 0, 1.0);
/* Blur */
- blur_node = clutter_blur_node_new (dst_width, dst_height, sigma);
+ blur_node = clutter_blur_node_new (dst_width, dst_height, radius);
clutter_paint_node_add_rectangle (blur_node,
&(ClutterActorBox) {
0.f, 0.f,